
import { DataSource } from 'typeorm'
import { UserEntity } from '../entities/user.mysql.entity'
import { UserSubscriber } from '@/user/entities/user.mysql.entity.subscriber'

export const UserProviders = [
  {
    import: [], // 导入数据源
    provide: "USER_REPOSITORY",
    useFactory: (dataSource: DataSource) => dataSource.getRepository(UserEntity),
    inject: ["MYSQL_DATA_SOURCE"] // 具名注入数据源
  },
  {
    provide: "USER_SUBSCRIBER",
    useFactory: (dataSource: DataSource) => new UserSubscriber(dataSource),
    inject: ["MYSQL_DATA_SOURCE"] // 具名注入数据源
  }
]
